---
title: "Reference: BraintrustExporter | Observability"
description: Braintrust exporter for Tracing
---

import PropertiesTable from "@site/src/components/PropertiesTable";

# BraintrustExporter

Sends Tracing data to Braintrust for eval and observability.

## Constructor

```typescript
new BraintrustExporter(config: BraintrustExporterConfig)
```

## BraintrustExporterConfig

```typescript
interface BraintrustExporterConfig extends BaseExporterConfig {
  apiKey?: string;
  endpoint?: string;
  projectName?: string;
  tuningParameters?: Record<string, any>;
}
```

Extends `BaseExporterConfig`, which includes:
- `logger?: IMastraLogger` - Logger instance
- `logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'` - Log level (default: INFO)

<PropertiesTable
  props={[
    {
      name: "apiKey",
      type: "string",
      description: "Braintrust API key",
      required: false,
    },
    {
      name: "endpoint",
      type: "string",
      description: "Custom Braintrust endpoint",
      required: false,
    },
    {
      name: "projectName",
      type: "string",
      description: "Project name (default: 'mastra-tracing')",
      required: false,
    },
    {
      name: "logLevel",
      type: "'debug' | 'info' | 'warn' | 'error'",
      description: "Logger level (default: 'warn')",
      required: false,
    },
    {
      name: "tuningParameters",
      type: "Record<string, any>",
      description: "Tuning parameters for Braintrust",
      required: false,
    },
  ]}
/>

## Methods

### exportTracingEvent

```typescript
async exportTracingEvent(event: TracingEvent): Promise<void>
```

Exports a tracing event to Braintrust.

### export

```typescript
async export(spans: ReadOnlySpan[]): Promise<void>
```

Batch exports spans to Braintrust.

### shutdown

```typescript
async shutdown(): Promise<void>
```

Flushes pending data and shuts down the client.

## Usage

```typescript
import { BraintrustExporter } from "@mastra/braintrust";

const exporter = new BraintrustExporter({
  apiKey: process.env.BRAINTRUST_API_KEY,
  projectName: "my-ai-project",
});
```

## Span Type Mapping

| Span Type                | Braintrust Type |
| --------------------------- | --------------- |
| `MODEL_GENERATION`          | `llm`           |
| `MODEL_CHUNK`               | `llm`           |
| `TOOL_CALL`                 | `tool`          |
| `MCP_TOOL_CALL`             | `tool`          |
| `WORKFLOW_CONDITIONAL_EVAL` | `function`      |
| `WORKFLOW_WAIT_EVENT`       | `function`      |
| All others                  | `task`          |
